para mtemp0
   if .not. impressora()
      retu(2)
   endif
   legal(8,6,22,77,'Retencao - IRRF')
   mmes =  '  /    '
   @ 10,8 say 'Mes/Ano   :' get mmes pict '99/9999'
   read
   if empty(ctod('01/'+mmes))
      mensa(10,'Dados invalidos',2)
      retu  
   endif
   sele 100
   use retirrf    
   mtitulo = .t.
   mpagina = 1
   tretencao2 := tretencao5 := 0    
   ttotal2    := ttotal5    := 0       
   sele retirrf           
   go top
   while .not. eof()
    if right(dtoc(recebto),7) # mmes
      skip
      loop
    endif
    if cancela = 'S'
       skip
       loop
    endif
    mretencao2 = acharetencao(2)
    if mretencao2 = 0 
       skip
       loop
    endif
    sele retencao
    seek 2
    mtemp = linha1
    sele retirrf             
    set devi to screen
    @ 15,8 say 'Data        : ' + dtoc(emissao)
    set devi to printer
**  set printer t  c:\video additive
    if mtitulo
       tit_rela('RETENCAO ' + mtemp0 + ' IRRF : ' + mmes,mpagina)
       mtitulo = .f.
       @ prow(),0   say chr(15)
       @ prow()+1,20 say 'Retencao : ' + mtemp
       @ prow()  ,20 say 'Retencao : ' + mtemp
       @ prow()+1,0 say repli('=',132)
       @ prow()+1,0 say '  NOTA       DATA DE        VALOR           DATA DE      VALOR DA        CONTRATANTE                                      CNPJ'
       @ prow()+1,0 say '  FISCAL     EMISSAO        BRUTO           RETENCAO     RETENCAO                                                             '                                  
       @ prow()+1,0 say repli('=',132)
    endif                               //   1234567890 1234567890
    mcliente = cliente
    sele clientes
    seek mcliente  
    mnome     = left(nome,40)
    mcgc      = cgc
    sele retirrf             
    mtotal    = total                   
    mlinha    = str(numero,7) + '   ' + dtoc(emissao) + trans(mtotal,'99,999,999.99') + space(6)
    mlinha   += dtoc(recebto)
    mlinha   += trans(mretencao2,'999,999,999.99') + space(4)
    mlinha   += mnome + '   ' + trans(mcgc,'@R 99.999.999/9999-99')
    @ prow()+1,2 say mlinha
    tretencao2 += mretencao2
    ttotal2    += total
    skip
    if prow() > 56
       eject
       mtitulo = .t.
       mpagina+=1
    endif
   enddo
   @ prow()+1,0  say repli('=',132)
   mlinha  = '  TOTAL ' + space(12) +  trans(ttotal2,'9999,999,999.99') + space(16) + trans(tretencao2,'999,999,999.99')
   @ prow()+1,0  say mlinha
   @ prow()+1,0  say repli('=',132)

   sele retirrf               
   go top
   while .not. eof()
    if right(dtoc(recebto),7) # mmes
      skip
      loop
    endif
    if cancela = 'S'
       skip
       loop
    endif
    mretencao5 = acharetencao(5)
    if mretencao5 = 0
       skip
       loop
    endif
    sele retencao
    seek 5
    mtemp = linha1
    sele retirrf                
    set devi to screen
    @ 15,8 say 'Data        : ' + dtoc(emissao)
    set devi to printer
    if ttotal5 = 0
       @ prow()+1,0 say repli('=',132)
       @ prow()+1,20 say 'Retencao : ' + mtemp
       @ prow()  ,20 say 'Retencao : ' + mtemp
       @ prow()  ,20 say 'Retencao : ' + mtemp
    endif
**  set printer to c:\video additive
    if mtitulo
       tit_rela('RETENCAO IRRF : ' + mmes,mpagina)
       mtitulo = .f.
       @ prow(),0   say chr(15)
       @ prow()+1,0 say '  NOTA       DATA DE                    DATA DE      VALOR DA  CONTRATANTE                                      CNPJ'
       @ prow()+1,0 say '  FISCAL     EMISSAO        VALOR       RETENCAO     RETENCAO                                                       '                                  
    endif                               //   1234567890 1234567890
    mcliente = cliente
    sele clientes
    seek mcliente  
    mnome     = left(nome,40)
    mcgc      = cgc
    sele retirrf           
    mtotal    = total                   
    mlinha    = str(numero,7) + ' ' + dtoc(emissao) + trans(mtotal,'99,999,999.99') + space(6)
    mlinha   += dtoc(recebto)
    mlinha   += trans(mretencao5,'999,999,999.99') + space(4)
    mlinha   += mnome + '   ' + trans(mcgc,'@R 99.999.999/9999-99')
    @ prow()+1,2 say mlinha
    tretencao5 += mretencao5
    ttotal5    += total
    skip
    if prow() > 56
       eject
       mtitulo = .t.
       mpagina+=1
    endif
   enddo
   if ttotal5 # 0
      @ prow()+1,0  say repli('=',132)
      mlinha  = 'TOTAL' + space(12)  + trans(ttotal5,'9999,999,999.99') + space(16) + trans(tretencao5,'999,999,999.99')
      @ prow()+1,0  say mlinha
      @ prow()+1,0  say repli('=',132)
   endif
   eject
   set devi to screen
   close retirrf     
retu

